﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DrawPosition : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler
{
    private Vector2 startPosion;
    public void OnDrag(PointerEventData eventData)
    {
        transform.localPosition = eventData.position + startPosion;
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        Debug.Log("OnPointerDown");
        startPosion = (Vector2)transform.localPosition - eventData.position;
        StopAllCoroutines();
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        Debug.Log("OnPointerEnter");
        StartCoroutine(WaitTime());
    }

    IEnumerator WaitTime()
    {
        yield return new WaitForSeconds(10);
        Destroy(gameObject);
    }
    // Use this for initialization
    void Start()
    {
        StartCoroutine(WaitTime());
    }

    // Update is called once per frame
    void Update()
    {

    }
}
